package GUI.Components;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.JOptionPane;
import javax.swing.JSpinner;
import javax.swing.JButton;
import javax.swing.JPopupMenu;
import javax.swing.JMenuItem;
import javax.swing.SpinnerModel;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

@SuppressWarnings("serial")
public class BasicGate extends JFrame 
{
	private JPanel contentPane;
	protected JButton ButtonOk = new JButton("Ok");
	protected JButton Buttoncanel = new JButton("Cancel");	
	protected SpinnerModel model = new javax.swing.SpinnerNumberModel(2, 2, 8, 1);
	protected JSpinner spinner = new JSpinner(model);
	protected int inputno;
	public BasicGate(String title) 
	{
		super(title);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		//flag=false;		
		//GridBag layout.YUUUCK!!!!!!!!
		setBounds(100, 100, 400, 221);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{36, 137, 39, 144, 0};
		gbl_contentPane.rowHeights = new int[]{43, 39, 46, 23, 0};
		gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		spinner.setMaximumSize(new Dimension(200, 50));
		GridBagConstraints gbc_spinner = new GridBagConstraints();
		gbc_spinner.fill = GridBagConstraints.BOTH;
		gbc_spinner.insets = new Insets(0, 0, 5, 0);
		gbc_spinner.gridwidth = 3;
		gbc_spinner.gridx = 1;
		gbc_spinner.gridy = 1;
		contentPane.add(spinner, gbc_spinner);
		GridBagConstraints gbc_ButtonOk = new GridBagConstraints();
		gbc_ButtonOk.anchor = GridBagConstraints.NORTHEAST;
		gbc_ButtonOk.insets = new Insets(0, 0, 0, 5);
		gbc_ButtonOk.gridx = 1;
		gbc_ButtonOk.gridy = 3;
		contentPane.add(ButtonOk, gbc_ButtonOk);
		GridBagConstraints gbc_Buttoncanel = new GridBagConstraints();
		gbc_Buttoncanel.anchor = GridBagConstraints.NORTHWEST;
		gbc_Buttoncanel.gridx = 3;
		gbc_Buttoncanel.gridy = 3;
		contentPane.add(Buttoncanel, gbc_Buttoncanel);		
		
		spinner.addChangeListener(new ChangeListener()
				{
					public void stateChanged(ChangeEvent event) 
					{
						inputno=(Integer) spinner.getValue();
						//JOptionPane.showMessageDialog(null, inputno);
					}					
				});		
		Buttoncanel.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent event) 
			{			
				inputno=2;
				dispose();
			}			
		});
	}
	public int getInputgates()
	{
		return inputno;
	}	
}
